import { STORAGE_KEY } from './config'

export default {
  SET_LANG(state, locale) {
    if (state.locales.indexOf(locale) !== -1) {
      console.log("SET_LANG=" + locale)
      state.locale = locale

    }
  },
  setToken(state, token) {
    state.token = token
  },
  removeToken(state) {
    state.token = null
  },
  login(state, userInfo) {
    state.userInfo = userInfo
    sessionStorage.setItem(STORAGE_KEY, JSON.stringify(userInfo))  //添加到sessionStorage
  },
  logout(state) {
    state.userInfo = null
    sessionStorage.removeItem(STORAGE_KEY)  //删除sessionStorage
  }
}

